package com.ruoyi.develop.factory.factoryLibrarySpare.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.factory.factoryLibrarySpare.mapper.FactoryLibrarySpareMapper;
import com.ruoyi.develop.factory.factoryLibrarySpare.domain.FactoryLibrarySpare;
import com.ruoyi.develop.factory.factoryLibrarySpare.service.IFactoryLibrarySpareService;

/**
 * 备品备件库存Service业务层处理
 * @author lmm
 * @date 2024-11-06
 */
@Service
public class FactoryLibrarySpareServiceImpl implements IFactoryLibrarySpareService {
    @Resource
    private FactoryLibrarySpareMapper factoryLibrarySpareMapper;

    /**
     * 查询备品备件库存
     * @param id 备品备件库存主键
     * @return 备品备件库存
     */
    @Override
    public FactoryLibrarySpare selectById(String id) {
        return factoryLibrarySpareMapper.selectById(id);
    }

    /**
     * 查询备品备件库存列表
     * @param entity 备品备件库存
     * @return 备品备件库存
     */
    @Override
    public List<FactoryLibrarySpare> selectList(FactoryLibrarySpare entity) {
        return factoryLibrarySpareMapper.selectList(entity);
    }

    /**
     * 新增备品备件库存
     * @param entity 备品备件库存
     * @return 结果
     */
    @Override
    public int insert(FactoryLibrarySpare entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return factoryLibrarySpareMapper.insert(entity);
    }

    /**
     * 修改备品备件库存
     * @param entity 备品备件库存
     * @return 结果
     */
    @Override
    public int update(FactoryLibrarySpare entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return factoryLibrarySpareMapper.update(entity);
    }

    /**
     * 批量删除备品备件库存
     * @param ids 需要删除的备品备件库存主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return factoryLibrarySpareMapper.deleteByIds(ids);
    }

    /**
     * 删除备品备件库存信息
     * @param id 备品备件库存主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return factoryLibrarySpareMapper.deleteById(id);
    }
}
